package com.spyz.P6_PartitionerAndWritableComparable;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Partitioner;

public class FlowPartitioner extends Partitioner<FlowBean, Text> {
    @Override
    public int getPartition(FlowBean flowBean, Text text, int i) {

        String phone = text.toString();

        String prePhone = phone.substring(0, 2);

        int partition;
        if (prePhone.equals("13")){
            partition= 1;
        }if (prePhone.equals("14")){
            partition = 2;
        }if (prePhone.equals("15")){
            partition = 3;
        }if (prePhone.equals("18")){
            partition = 4;
        }else{
            partition = 0;
        }
        return partition;
    }
}
